<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Question2
 *
 * @author Administrator
 */
require_once 'Question.php';
require_once 'Connection.php';

class Question2 {
    //put your code here

    public $url;
    public $correct;

    public function   __construct() {
        $this->url = "";
        $this->correct = 1;
    }

    public function getQuestion($iNumQuestion=30){
        $conn1 = new Connection();
        $conn = $conn1->open();

        $query = 'SELECT * FROM `audio-entity` WHERE id >= (SELECT FLOOR( MAX(id) * RAND()) FROM `audio-entity` ) ORDER BY id LIMIT '.$iNumQuestion;
        $result = mysql_query($query, $conn) or die("Could not connect").mysql_error();
        $questions = array();
        while($set = mysql_fetch_array($result, MYSQLI_ASSOC))
        {
            $temp = new Question2();
            $temp->id = $set['id'];
            $temp->type = $set['id_type'];
            $temp->url = $set['url'];
            $temp->correct = $set['correct'];
            $questions[] = $temp;
        }
        mysql_close($conn);
        return $questions;
    }
}
?>
